package com.wharf.base.controller;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.wharf.base.model.AddGoods;
import com.wharf.base.model.Goods;
import com.wharf.base.service.GoodsInfoService;

/**商品管理*/
@RestController
@RequestMapping("/back")
public class GoodsController {
	
	@Autowired
	private GoodsInfoService goodsService;
	
	@ResponseBody
	@GetMapping("/goodshow")
	public ResponseEntity<List<Goods>> goodsInfoShow(){
		List<Goods> show = goodsService.goodsShow();
		return new ResponseEntity<List<Goods>>(show,HttpStatus.OK);
	}
	
	//商品搜索
	@ResponseBody
	@GetMapping("/goodsearch")
	public ResponseEntity<List<Goods>> searchShow(String goodsName){
		List<Goods> search = goodsService.search(goodsName);
		return new ResponseEntity<List<Goods>>(search,HttpStatus.OK);
	}
	
	//商品添加
	@GetMapping("/goodAdd")
	public boolean addGoods(AddGoods add){
		boolean i = goodsService.insertGoods(add);
		return i;
	}
	
	//商品删除
	@GetMapping("/deleGoods")
	public boolean delGoods(Integer id) {
		boolean delById = goodsService.delById(id);
		return delById;
	}
}
